<?php
header("Content-type: text/html; charset=utf-8");
require_once 'f2fpay/model/builder/AlipayTradePayContentBuilder.php';
require_once 'f2fpay/service/AlipayTradeService.php';

$data = json_decode(file_get_contents('php://input'), true);
if(is_array($data) && !empty($data)){
    // 订单号
    $outTradeNo = $data['outTradeNo'];
    // 描述
    $subject = $data['subject'];
    // 总金额
    $totalAmount = $data['totalAmount'];
    // 授权码
    $authCode = $data['authCode'];
    // 支付超时，线下扫码交易定义为5分钟
    $timeExpress = "5m";
    //第三方应用授权令牌,商户授权系统商开发模式下使用
    $appAuthToken = "";
    // 创建请求builder，设置请求参数
    $barPayRequestBuilder = new AlipayTradePayContentBuilder();
    $barPayRequestBuilder->setOutTradeNo($outTradeNo);
    $barPayRequestBuilder->setTotalAmount($totalAmount);
    $barPayRequestBuilder->setAuthCode($authCode);
    $barPayRequestBuilder->setTimeExpress($timeExpress);
    $barPayRequestBuilder->setSubject($subject);
    $barPayRequestBuilder->setAppAuthToken($appAuthToken);
    // 调用barPay方法获取当面付应答
    $barPay = new AlipayTradeService($config);
    $barPayResult = $barPay->barPay($barPayRequestBuilder);

    echo json_encode($barPayResult->getResponse());
}

